//
//  MaiTianLogTableViewCell.m
//  lmq
//
//  Created by 马田成 on 2017/3/15.
//  Copyright © 2017年 yuanxin. All rights reserved.
//

#import "MaiTianLogTableViewCell.h"
#import "MaiTianLogModel.h"
#import "MaiTianLogCollectionViewCell.h"
#import "MaiTianLogViewController.h"
#import "UIImageView+WebCache.h"
#import "MaiTianOtherModel.h"

@implementation MaiTianLogTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.arrOfPic = [[NSMutableArray alloc] init];
    self.vc = [[MaiTianLogViewController alloc] init];
    
    
    
//    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
//    layout.minimumLineSpacing = 10;
//    layout.minimumInteritemSpacing = 10;
//    layout.itemSize = CGSizeMake((DEF_SCREEN_WIDTH - 60) / 3, 140);
//    //直接布局 上下左右
//    layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
//    
////    NSInteger num = numOfCount / 3;
//    
//    
//    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 200, DEF_SCREEN_WIDTH, 650) collectionViewLayout:layout];
//    
//
//    
//    [self.collectionView layoutIfNeeded];
//    //    self.automaticallyAdjustsScrollViewInsets = NO;
//    self.collectionView.pagingEnabled = NO;
//    self.collectionView.delegate = self;
//    self.collectionView.dataSource = self;
//    self.collectionView.scrollEnabled = NO;
//    
//    
//    [self.collectionView registerNib:[UINib nibWithNibName:@"MaiTianLogCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"MaiTianLogCollectionViewCell"];
//    
//    self.collectionView.showsHorizontalScrollIndicator = NO;
//    
//    //    self.collectionView.bounces = NO;
//    self.collectionView.backgroundColor = [UIColor whiteColor];
//    [self addSubview:self.collectionView];
//    
    
    
    
    // Initialization code
}

- (void)setNum:(NSString *)num{
    
    _num = num;
//    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
//    layout.minimumLineSpacing = 10;
//    layout.minimumInteritemSpacing = 10;
//    layout.itemSize = CGSizeMake((DEF_SCREEN_WIDTH - 60) / 3, 140);
//    //直接布局 上下左右
//    layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
//    
//    //    NSInteger num = numOfCount / 3;
//    
//    NSInteger hei = self.contentLabel.frame.size.height;
//    
//    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 400, DEF_SCREEN_WIDTH, 140 *[num intValue]) collectionViewLayout:layout];
//    
//    
//    
//    [self.collectionView layoutIfNeeded];
//    //    self.automaticallyAdjustsScrollViewInsets = NO;
//    self.collectionView.pagingEnabled = NO;
//    self.collectionView.delegate = self;
//    self.collectionView.dataSource = self;
//    self.collectionView.scrollEnabled = NO;
//    
//    
//    [self.collectionView registerNib:[UINib nibWithNibName:@"MaiTianLogCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"MaiTianLogCollectionViewCell"];
//    
//    self.collectionView.showsHorizontalScrollIndicator = NO;
//    
//    //    self.collectionView.bounces = NO;
//    self.collectionView.backgroundColor = [UIColor whiteColor];
//    [self addSubview:self.collectionView];
//    
//    _num = num;


    
    [self.MaiTianCollectionView layoutIfNeeded];
    //    self.automaticallyAdjustsScrollViewInsets = NO;
    self.MaiTianCollectionView.pagingEnabled = NO;
    self.MaiTianCollectionView.delegate = self;
    self.MaiTianCollectionView.dataSource = self;
    self.MaiTianCollectionView.scrollEnabled = NO;
    
    [self.MaiTianCollectionView registerNib:[UINib nibWithNibName:@"MaiTianLogCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"MaiTianLogCollectionViewCell"];
    
    self.MaiTianCollectionView.showsHorizontalScrollIndicator = NO;
    
    //    self.collectionView.bounces = NO;
    self.MaiTianCollectionView.backgroundColor = [UIColor whiteColor];

    

}


//类别
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
    
}
//数量
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    NSLog(@"LLLLLLLLLLLLLLLLLLLLLLLLL%lu", (unsigned long)self.arrOfPic.count);
//    numOfCount = self.arrOfPic.count;
    
    
    return self.arrOfPic.count;
    
    
    
}
//内容

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    MaiTianLogCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MaiTianLogCollectionViewCell" forIndexPath:indexPath];
    
    
    
    
//    NSString *strPic = @"http://lmq.quyum.cn/";
//    NSString *str = [strPic stringByAppendingString:[self.arrOfPic[indexPath.row] valueForKey:@"path"]];
    
    NSString *urlWare=[self.arrOfPic[indexPath.row] valueForKey:@"path"];
    NSString *str=manage(AP_HOST, urlWare);
    
    NSString *strUrl = [str stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
    
    [cell.picImage sd_setImageWithURL:[NSURL URLWithString:strUrl] placeholderImage:[UIImage imageNamed:@"liyi"]];
    
    
    
    return cell;
    
    
    
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake((DEF_SCREEN_WIDTH - 60) / 3, 140);
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
- (void)setMaiTianModel:(MaiTianLogModel *)maiTianModel{
    
    self.titleLabel.text = maiTianModel.title;
    self.contentLabel.text = maiTianModel.content;
    self.titleTimeLabel.text = maiTianModel.time;
    
//    self.dataArr = [NSMutableArray array];
//    for (NSDictionary *dic in maiTianModel.pic) {
//        MaiTianOtherModel *model = [[MaiTianOtherModel alloc] init];
//        [model setValuesForKeysWithDictionary:dic];
//        [self.dataArr addObject:model];
//        
//    }
    
    
    
}

@end
